home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 November / PCWorld_2007-11_cd.bin / v cisle / winuae / InstallWinUAE1440.exe / Docs / README.pci < prev    next >
Text File  |  2000-12-14  |  18KB  |  368 lines

  1. This describes how to get Virge and Virge/DX cards working under
  2. UAE-JIT if you are using Linux. 
  3.  
  4. ************************************************************************
  5. * EVERYTHING DESCRIBED IN HERE IS A HACK. IF YOU MANAGE TO DAMAGE YOUR *
  6. * HARDWARE, SOFTWARE OR DATA --- BAD LUCK! I AM NOT LIABLE IN ANY WAY! *
  7. * IF THE IDEA OF USING A COMMAND-LINE FRIGHTENS YOU, DO NOT READ ON!   *
  8. ************************************************************************
  9.  
  10. OK, scared yet? No need to be --- just follow the instructions, and if
  11. things don't work, experiment a bit before you send a cry for help my
  12. way, OK?
  13.  
  14.  
  15. A) The Easy Part --- a single Virge
  16. ===================================
  17.  
  18. To use a Virge PCI card under UAE-JIT, you need several things:
  19.  
  20.    * A Virge card (well, duh!)
  21.    * Another gfx card that you will use for your X display (This is 
  22.      important! You must not use the Virge for this! If all else fails,
  23.      try a remote X server)
  24.    * The CGX3 Virge drivers from http://www.vgr.com/mediator/
  25.      Get the October 26th release.
  26.    * The pci.library that comes with UAE-JIT
  27.    * XFree86 4.0x
  28.    * A halfway recent linux kernel
  29.    * A pci enabled version of UAE-JIT (i.e. something "bleeding edge",
  30.      and newer than Everton. You probably already have it if you read
  31.      this!)
  32.  
  33. Now put the Virge card into a PCI slot on your machine, make sure it
  34. is *not* the card the machine uses to boot (look for "initialize VGA first"
  35. in the BIOS, sometimes hidden in some rather unintuitive place, and set
  36. it to "AGP"). Boot into linux, and at a command line type
  37.  
  38.     # pcitweak -l
  39.  
  40. (the '#' is the shell prompt I use. Don't type it!)
  41. You should get output that looks something like this:
  42.  
  43.     PCI: Probing config type using method 1
  44.     PCI: Config type is 1
  45.     PCI: PCI scan (all values are in hex)
  46.     PCI: 00:00:0: chip 8086,7190 card 0000,0000 rev 03 class 06,00,00 hdr 00
  47.     PCI: 00:01:0: chip 8086,7191 card 0000,0000 rev 03 class 06,04,00 hdr 01
  48.     PCI: 00:07:0: chip 8086,7110 card 0000,0000 rev 02 class 06,01,00 hdr 80
  49.     PCI: 00:07:1: chip 8086,7111 card 0000,0000 rev 01 class 01,01,80 hdr 00
  50.     PCI: 00:07:2: chip 8086,7112 card 0000,0000 rev 01 class 0c,03,00 hdr 00
  51.     PCI: 00:07:3: chip 8086,7113 card 0000,0000 rev 02 class 06,80,00 hdr 00
  52.     PCI: 00:09:0: chip 10ec,8029 card 0000,0000 rev 00 class 02,00,00 hdr 00
  53.     PCI: 00:0d:0: chip 5333,8a01 card 5333,8a01 rev 01 class 03,00,00 hdr 00
  54.     PCI: 00:0f:0: chip 5333,8a01 card 5333,8a01 rev 01 class 03,00,00 hdr 00
  55.     PCI: 01:01:0: chip 1023,9750 card 1023,9750 rev f3 class 03,00,00 hdr 00
  56.     PCI: End of PCI scan
  57.  
  58. What you are looking for are lines that have "5333,8a01" or "5333,5631" in
  59. them (those are Virge/DX and Virge cards, respectively). Take down the
  60. field that looks like "00:0d:0" for those lines. That's the identifier for
  61. those cards. Yes, I have two in the machine I took the example from.
  62. You might also want to write down the identifier for your "main" graphics
  63. card. That should be the only other one that has "class 03", and often
  64. lives on its own bus (that's the first field in the identifier).
  65.  
  66. Next, you need to tell UAE-JIT about the PCI cards it is supposed to see.
  67. The pci library emulation will not allow the emulated Amiga access to anything
  68. else, which should reduce the risk of crashing your machine a tad....
  69. To tell UAE about the devices, add a line like this to your UAE config
  70. file:
  71.  
  72.    pci_devices=!0.f.0:!0.d.0:!*1.1.0
  73.  
  74. OK, this obviously needs explanation... "pci_devices" is assigned a string.
  75. That string consists of a number of device descriptions, separated by ':'.
  76. So the above has three device descriptions: "!0.f.0", "!0.d.0" and "!*1.1.0".
  77. Except for the '!' and '*', those correspond to the identifiers you took down
  78. in the previous step --- for me, "0.f.0" is one of my Virge/DX cards,
  79. "0.d.0" is the other, and "1.1.0" is the Trident card that I run X on
  80. (I assume that you are flexible enough to replace colons with periods ;-).
  81. Each device can optionally be prefixed by '!' and '*' (in that order!).
  82.  
  83. The '!' means that UAE should not be concerned about the device already
  84. being active. This is "active" in a PCI sense. Unfortunately, UAE needs
  85. to activate a device to use it, and doesn't currently deactivate it. So
  86. you pretty much need the '!' for now, because otherwise you will only
  87. ever be able to use the PCI emulation once....
  88. The '*' indicates your main display. UAE will never make this visible to
  89. the Amiga. In fact, at the moment it doesn't do *anything* with it.
  90. Eventually, however, it will need to know about that VGA device to do
  91. proper initialization of the Virge, so it's probably a good idea to
  92. put it in there already. 
  93.  
  94. Unfortunately, there still is a problem with getting the Virge cards
  95. properly initialized by the CGX3 drivers --- it seems as if I/O to the
  96. cards never makes it through. That's not really a showstopper, as the
  97. Virge has memory-mapped I/O which can be used instead, and the pci emulation
  98. takes care of redirecting the I/O. BUT(!) you need to get the Virge cards
  99. initialized. 
  100. That's what you need XFree86 4.0x for. You will need to set up a config
  101. file in some place to run it on your Virge card. Make sure you point it
  102. at the right card, and tell it to use the Virge driver. I have a device
  103. section like this
  104.  
  105.     Section "Device"
  106.         Identifier  "virge"
  107.         BusID      "PCI:0:13:0"
  108.         Driver      "s3virge"
  109.     EndSection
  110.  
  111. (the "13" is the "0d" from the identifier --- a=10, b=11, c=12, d=13, e=14,
  112. f=15). If I wanted to use the Virge on 00:0f:0, I'd use 15 instead of 13.
  113.  
  114. Setting up X can be tricky, but XF86 4.0 has a great config file, some good
  115. documentation (and some not so good :( ), and quite frankly, I can't help
  116. you. If you can't get this going, ask in the appropriate newsgroup or
  117. read some more documentation, ok?
  118.  
  119. Once your config file is done, you can start a bare-bones X server on 
  120. the Virge card by typing
  121.  
  122.     # XFree86 -xf86config your_virge_config_file :1 &
  123.  
  124. This will start a _second_ X server, in addition to the one you are already
  125. running on your "real" gfx card (you are, right?). Note that there won't
  126. be anything to see, just the stippled background. That's all that's needed
  127. to set up the card.
  128.  
  129. Once you have managed to do this, its easy the rest of the way. So don't
  130. give up just yet....
  131.  
  132. Now switch back to your "real" X server (usually CTRL-ALT-F7 will do the trick)
  133. and start UAE. Copy "pci.library" to your libs: directory.
  134.  
  135. Next, uncompress the Elbox archive, and choose "Install".  WARNING!
  136. WARNING! WARNING! This will trash your P96 setup. So make sure you
  137. have a backup to go back to if things don't work out, or if you just
  138. want P96 back. You have been warned!
  139.  
  140. When the install is complete, quit UAE and restart it. If all went well,
  141. you will now see the Cybergraphics logo appear on the monitor connected
  142. to the Virge, and then have Workbench appear on it. Hooray! You are now
  143. running Cybergfx, and the card is fully under the control of the Elbox
  144. driver. You can do everything with it that you could do with a "real"
  145. Mediator and Virge --- define your own modes with cgxmode, run software
  146. on it, drag screens.....
  147. Note, however, that UAE itself doesn't know anything about that gfx card.
  148. It still talks to you through the window on the "real" X server, and if
  149. you move the mouse out of that window, UAE loses it. So you might want
  150. to go fullscreen (F12-s if you have DGA modes enabled). 
  151.  
  152. Worse yet, UAE doesn't know that you probably aren't interested in the
  153. ECS output, and thus keeps on emulating the native Amiga video system.
  154. Sometimes, that might be what you want, but usually it isn't. So you
  155. might want to disable that part of the emulation, by pressing F12-i.
  156. Just remember to press F12-i again when you actually want to see the
  157. ECS output, for example because you started a game ;-). UAE-JIT will
  158. put "NAT" at the end of the lines it prints every second if the native
  159. ECS graphics are still being emulated, so if you can see that output,
  160. you'll get a reminder.
  161.  
  162. Got it working? Great! Enjoy it, and maybe have a look at the next section.
  163.  
  164. Didn't get it working? Try again. And again. And if it still doesn't work,
  165. and you think you should mail me (bmeyer@csse.monash.edu.au) for help, be
  166. sure to include as much detail as possible about your system, what happens,
  167. what doesn't happen, and so on.
  168.  
  169.  
  170. B) For Bravehearts Only --- using more than one Virge
  171. =====================================================
  172.  
  173. The free Elbox drivers don't actually support more than one card. This
  174. is due to some hardware limitations of the Mediator, which it is aimed
  175. at. So to get more than one to work under UAE requires some trickery.
  176. What essentially happens is that each card gets "its own" PCI interface,
  177. and is the only one using it (and thus works). 
  178.  
  179. Unfortunately, the drivers weren't meant to do that, either, and have
  180. some names and values hardcoded in. You'll need to put the included
  181. "patchVirge" program in the same directory as the "MediatorViRGE" driver
  182. file. Then run it (from a linux command line --- it's a linux/x86 program!)
  183. by typing
  184.  
  185.    # ./patchVirge 1
  186.  
  187. which should output
  188.  
  189.     replacing pattern 1, pos 577
  190.     replacing pattern 2, pos 617
  191.     replacing pattern 2, pos 745
  192.     replacing pattern 3, pos 1806
  193.     replacing pattern 2, pos 1818
  194.     replacing pattern 2, pos 1832
  195.     replacing pattern 2, pos 1862
  196.     replacing pattern 2, pos 1910
  197.     replacing pattern 2, pos 2002
  198.     replacing pattern 4, pos 2486
  199.     replacing pattern 1, pos 35118
  200.     replacing pattern 1, pos 35184
  201.     replacing pattern 1, pos 35210
  202.     replacing pattern 1, pos 35228
  203.     replacing pattern 2, pos 52118
  204.     replacing pattern 1, pos 53076
  205.     replacing pattern 1, pos 53100
  206.     replacing pattern 1, pos 53116
  207.     Replaced 18 patterns
  208.  
  209. and produce a file "MediatorViRGE.1". Repeat with
  210.  
  211.    # ./patchVirge 2
  212.  
  213. and
  214.  
  215.    # ./patchVirge 3
  216.  
  217. For the sake of symmetry, you can also run
  218.  
  219.    # ./patchVirge 0
  220.  
  221. and get a "MediatorViRGE.0", but apart from slightly different mode names, 
  222. that one is identical to the original MediatorViRGE.
  223.  
  224. Each of these files is a completely functional driver. Each of them will
  225. produce screen modes with slightly different modenames, and (more importantly)
  226. with different mode ids (and don't ask how long it took to find what bytes
  227. to patch for *that* ;-). Back in UAE, copy as many of them as you have
  228. Virge cards into the Devs/Monitors of your boot disk. WARNING! The files
  229. might not be marked executable. After copying, make sure you select each,
  230. use the "icons->information.." menu item, activate "executable" and 
  231. "save" the changed info.
  232. If you use MediatorViRGE.0 (I do, so it might be a good idea), you might
  233. want to remove the original MediatorViRGE driver from Devs/Monitors, because
  234. otherwise you might get mode-id conflicts (which are a real pain to track
  235. down, as CGX is very quiet about them).
  236. One more thing --- each of those drivers uses its own, individual copy of
  237. the "pci.library". MediatorViRGE.0 uses "pc0.library", MediatorViRGE.1 uses
  238. "pc1.library" and so on. So you need to copy the right libraries to libs:,
  239. or things won't work. Except for the name, the libraries are exactly
  240. identical, but you need to have separate ones. You cannot just copy one
  241. library over and over again, or even use links --- the names of the libraries
  242. are contained inside as well.
  243. Oh, and one more "one more thing". You need to copy a few files in 
  244. "prefs/env-archive/cybergraphx" on your boot drive. There should be a file
  245. "MediatorViRGEMonitor" there --- copy it to "Mediato1ViRGEMonitor",
  246. "Mediato2VirgeMonitor" and so on, and of course "Mediato0ViRGEMonitor" as
  247. well if you use that. Don't worry about the original file; You can keep it
  248. without causing problems.
  249.  
  250. Now exit and restart UAE, and the cards should be assigned to the drivers
  251. in the order you mention them in the config file. You can't currently
  252. use more than 4 cards, and you should not have more than 4 drivers
  253. installed at any one time --- but apart from that, it doesn't matter if
  254. you have more drivers installed than you have cards, because each card
  255. will only be found once. For example, I have 4 drivers installed, and
  256. currently only have 2 Virge cards.
  257. [Note --- I consider it unlikely, but it is possible that you actually need
  258. to install the full CGX3 package, rather than just the Elbox version. I did
  259. so while bug hunting, so I cannot promise that it works without. I can't see
  260. why it wouldn't, though.]
  261.  
  262. C) Known Bugs
  263. =============
  264. You certainly don't want to do a soft reset --- the PCI emulation isn't
  265. up to that yet, and will not release the cards. Things will crash one
  266. way or another. Just don't do it!
  267.  
  268. You *CANNOT* use anything but the Virge driver. No other drivers are
  269. publicly available, anyway, but just in case you somehow get your hands
  270. on one --- IT WON'T WORK. If you can legally send it my way, I might be
  271. able to make it work, but right now, there is quite a bit of Virge
  272. specific stuff in there.
  273.  
  274. For some reason, the bottom line of the screen is displayed above the top
  275. line. I think this is a driver problem, and has nothing to do with the
  276. pci emulation.
  277.  
  278. Some 2-monitor configurations in Shapeshifter may give corrupt screen
  279. display on one monitor. Once again, I suspect the problem is on the
  280. Amiga side.
  281.  
  282. D) How did this come about?
  283. ===========================
  284.  
  285. A lot of trial and error, and a lot of "where the $@%#$^@ did that value
  286. come from", which UAE is just great for. And of course the good old
  287. "Let's return some bogus value, and see where it shows up", which UAE
  288. is also great for.
  289.  
  290. I have never seen anything but a picture of a Mediator, and I have
  291. never seen any Mediator related code other than the Virge driver. This
  292. means that anything the Virge driver doesn't use, the emulation
  293. doesn't support. There are many pci.library functions for which I have
  294. absolutely no idea what they are supposed to do --- the Virge drivers
  295. only use two.
  296.  
  297. Personally, I think that a proper pci.library emulation, developed from
  298. a full and detailed spec, would be a GREAT tool for driver development.
  299. Developing in an emulation allows for great logging and debugging support
  300. that working on the real iron just can't provide (Logging every byte ever
  301. written to your device is just so much more useful than simply seeing
  302. your Amiga crash and burn). But it appears that Elbox likes to play
  303. their hand close to their chest, and thus are unwilling to open up
  304. their specs. I think that's a mistake, but I am not in a position to
  305. make any decisions....
  306.  
  307.  
  308. E) If you have a look at the source...
  309. ======================================
  310.  
  311. ...you will notice a couple of #define's at in the file pcilib.c, switching
  312. on or off features.
  313.  
  314. The first one is "USE_REAL_IO". It is related to the already mentioned
  315. problems with initializing the Virge cards --- if you set it to 1, 
  316. the pci emulation will use the PCI I/O space rather than the memory
  317. mapped I/O of the Virge cards. In that case, you *must* provide an
  318. entry in pci_devices for your main VGA card (it needs to be deactivated
  319. temporarily when I/O to the Virge occurs). This has never worked for me.
  320. It might work in a machine that has just one PCI bus, and no AGP bus,
  321. or if your main VGA card is on the same PCI bus as the Virge. If you get
  322. this to work, tell me! 
  323. If the PCI emulation ever is to support other drivers, such as the network
  324. one that seems to float around, this will need to be set to 1. But before
  325. that happens, I need to find out why XF86 can wake up the Virge in my
  326. machine, but the emulated Amiga's Virge driver can't.
  327.  
  328. The second one is called "EVIL_HACK". It's evil. It's a hack. It also
  329. saves loads and loads of CPU time ;-). 
  330. The Mediator is limited to an 8M address window, which means that it
  331. cannot at the same time have access to the VGA frame buffer of the
  332. Virge *and* the memory-mapped I/O area (which is at
  333. frame_buffer_address+16MB). So each time it wants to access I/O, it
  334. switches the window 16MB forward, does its access, and switches 
  335. the window back. And the driver isn't very clever about it; If it 
  336. wants to do two accesses to I/O, it still switches the window 
  337. back in between.
  338. Now, on a Mediator, switching the window is cheap --- store the value in
  339. some hardware register, and whatever is in that register gets added to
  340. the address of each access to the PCI space. Under UAE, it's not cheap.
  341. It requires un-mmapping 8M of memory, and mmapping another 8M. Each time.
  342. Quite often only to reverse the mappings immediately afterwards. Not good!
  343. Fortunately, UAE is not limited to a 24 bit address space. So if you enable
  344. "EVIL_HACK", the pci emulation will search for a 32M address window instead,
  345. and map the whole 32M space of the Virge at the same time. 
  346. So far, so good. However, the Virge driver doesn't expect this, and
  347. rather assumes a window switch to provide new stuff in the first 8M of
  348. Mediator space. And unfortunately, the "switch window" routine doesn't
  349. return the base address of the Mediator space to use (Bad Thinking there,
  350. Elbox! You are locking yourself into your current scheme!), so changing
  351. that assumption is not possible in a non-evil way. However, it *is* possible
  352. to change in a completely evil way --- after each time the window switch
  353. function is called, the driver loads the Mediator window base address from
  354. its own, driver-local storage space. It always loads it from the same spot.
  355. So the evil thing to do is to "mess with its mind", i.e. to have the
  356. window switch emulation leave the mappings alone, and instead change 
  357. that base address variable. 
  358. Now, mind you --- it's not the pci.library's to change, and where it
  359. can be found could quite well be completely different for the next
  360. driver version.  Messing with the internals of another program is
  361. certainly not "the done thing". But if it saves CPU cycles, who am I
  362. to reject it?
  363.  
  364.  
  365.  
  366.  
  367.  
  368.